.TH std::valarray::size 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::valarray::size \- std::valarray::size

.SH Synopsis
   std::size_t size() const;

   Returns the number of elements in the valarray.

.SH Parameters

   \fI(none)\fP

.SH Return value

   Number of elements in the valarray.

.SH Example


// Run this code

 #include <iostream>
 #include <valarray>

 int main()
 {
     std::valarray<double> a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
     std::cout << "Average: " << a.sum()/a.size() << '\\n';
 }

.SH Output:

 Average: 5.5

.SH See also

   resize changes the size of valarray
          \fI(public member function)\fP
